package com.test.designModel.single;

public class Singleton {
    private volatile static Singleton singleton;  
    private Singleton (){}  
    public static Singleton getSingleton() {
    if (singleton == null) {  
        synchronized (Singleton.class) {  
            if (singleton == null) {  
                singleton = new Singleton();  
            }  
        }  
    }  
    return singleton;  
    }

    public static void  main(String[] args){
        Singleton singleton=Singleton.getSingleton();
        Singleton singleton2=Singleton.getSingleton();
        System.out.println(singleton==singleton2);
    }

}

